package com.sykj.weichat.web;

import java.util.List;

import javax.servlet.http.HttpSession;

import com.sykj.weichat.service.BisBagProjectService;
import com.sykj.weichat.service.BisCustomUserService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sykj.weichat.model.BisBagProject;
import com.sykj.weichat.model.BisCustomUser;
import com.sykj.weichat.model.BisNurseProject;
import com.sykj.weichat.model.BisShop;
import com.sykj.util.ResultBody;
import com.sykj.weichat.service.BisNurseProjectService;
import com.sykj.weichat.service.BisShopService;

/**
 * 
 * 类名:com.sykj.weichat.web.WechatProjectController
 * 描述:微信项目相关处理
 * @author 张孝柱
 * 创建时间:2018年9月6日 
 * 修改说明:
 */
@Controller
@RequestMapping("/weichat/project")
public class WeichatProjectController {
	@Autowired
	BisNurseProjectService BisNurseProjectservice;
	@Autowired
	BisBagProjectService BisBagProjectService;
	@Autowired
	BisCustomUserService BisCustomUserService;
	@Autowired
	BisShopService BisShopService;
	@RequestMapping("/")
	public String project(Model model) {
		List<BisNurseProject> getall = BisNurseProjectservice.getall();
		model.addAttribute("projectList", getall);
		return "weichat/project/findProject.jsp";
	}
	/**
	 * 查找项目  初始化我的项目
	 * @param request
	 * @param response
	 * @param session
	 * @return
	 * @throws IOException 
	 */
	@RequestMapping("initMyProject")
	public String initMyProject(String bag_id,Model model) {
		model.addAttribute("bag_id", bag_id);
		return "weichat/project/myProject.jsp";
	}
	/**
	 * 
	 * 简要说明：搜索护理订单
	 * 编写者：张孝柱
     * 创建时间:2018年9月14日 
	 * @param 说明
	 * @return 说明
	 */
	@RequestMapping(value = "listMyProject")
	@ResponseBody
	public ResultBody listMyProject(BisBagProject bagProject,HttpSession session){
		String custom_user_id = (String) session.getAttribute("custom_user_id");
		bagProject.setCustom_user_id(custom_user_id);
		List<BisBagProject> getall = BisBagProjectService.getall(bagProject);
		return ResultBody.getData(getall.size(), getall, "");
	}
	/**
	 * 查找项目
	 * @return
	 * @throws IOException 
	 */
	@RequestMapping(value = "showProjectDetail")
	public String showProjectDetail(String project_id,Model model){
		BisNurseProject users = BisNurseProjectservice.getUsers(project_id);
		model.addAttribute("project", users);
		return "weichat/project/showProjectDetail.jsp";
	}
	/**
	 * 
	 * 简要说明：调到预约项目
	 * 编写者：张孝柱
     * 创建时间:2018年9月8日 
	 * @param 说明
	 * @return 说明
	 */
	@RequestMapping(value = "goSubscribeProject")
	public String goSubscribeProject(String project_id,String shop_id,Model model,HttpSession session){
		String custom_user_id = (String) session.getAttribute("custom_user_id");
		String mobile = (String) session.getAttribute("mobile");
		model.addAttribute("mobile", mobile);
		BisNurseProject users = BisNurseProjectservice.getUsers(project_id);
		BisCustomUser users2 = BisCustomUserService.getUsers(custom_user_id);
		BisShop getuser = BisShopService.getuser(shop_id);
		model.addAttribute("project", users);
		model.addAttribute("customUserPO", users2);
		model.addAttribute("shopPO", getuser);
		return "weichat/project/subscribeProject.jsp";
		
	}
}
